package com.rlax.ccdemo.service.product.interfaces.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.rlax.ccdemo.service.api.user.dto.UpmsUserDTO;
import com.rlax.ccdemo.service.api.user.fegin.IUpmsUserApi;
import com.rlax.corebin.boot.web.base.BaseController;
import com.rlax.corebin.core.result.R;
import com.rlax.corebin.security.annotation.PreAuth;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户表 控制器
 *
 * @author Rlax
 * @since 2020-12-10
 */
@RestController
@AllArgsConstructor
@RequestMapping("/product")
@Api(value = "用户表", tags = "用户表接口")
@PreAuth(replace = "product:")
public class ProductDemoController extends BaseController {

	private final IUpmsUserApi upmsUserApi;

	/**
	 * 详情，无需鉴权
	 */
	@GetMapping("/detail")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "id")
	public R<UpmsUserDTO> info(Long id) {
		return upmsUserApi.get(id);
	}


	/**
	 * 详情，需要鉴权
	 */
	@PreAuth("hasAnyPermission('{}detail')")
	@GetMapping("/detail-need-auth")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "id")
	public R<UpmsUserDTO> detailNeedAuth(Long id) {
		return upmsUserApi.get(id);
	}
}
